package br.com.intelsys.crawler.playground;

import java.util.ArrayList;
import java.util.List;

import br.com.intelsys.crawler.BasicControllerData;
import br.com.intelsys.crawler.CrawledPage;
import br.com.intelsys.crawler.CrawlerBrowser;

public class RunCraw implements Runnable {
	private final String url;

	public RunCraw(String url) {
		this.url = url;
	}

	public static void main(String[] args) throws Exception {
		List<Thread> tList = new ArrayList<Thread>();
		tList.add(new Thread(new RunCraw("http://www.molequemateiro.com.br/")));
		for (Thread t : tList) {
			t.start();
		}

	}

	public void run() {
		System.out.println("Iniciando: " + url);
		CrawlerBrowser cb = new CrawlerBrowser(url);
		cb.threadSize(10).maxPagesToFetch(500);
		BasicControllerData controllerData = (BasicControllerData) cb.start();
		for (CrawledPage page : controllerData.getCrawledPageSet()) {
			System.out.println(url + "      " + page.getUrl());
		}
		System.out.println("FIM de: " + url);
	}
}
